{extend name="common/base" /}
{block name="body"} 
<div class="Content" id="content">
    <div class="container">
        <form class="layui-form search-form SearchCom " lay-filter="searchForm">
            <div class="OrderSearcItem">
                <div class="input-inline ">
                    <select name="category" lay-search lay-filter="category">
                        <option value="">收入记录</option>
                    </select>
                </div>
            </div>
        </form>
        <table class="layui-hide" id="withdrawTable" lay-filter="withdrawTable"></table>

    </div>
</div>
{/block}
{block name="js"} 
<script>
    changeTitleName('提现记录');
    layui.use(['table', 'layer', 'form'], function () {
            var table = layui.table;
            var layer = layui.layer;
            var form = layui.form;

            // 渲染表格
            var tableIns  = table.render({
            elem: '#withdrawTable',
            url: '/merchant/merchant-finance-log',
            cols: [[
                { field: 'amount', title: '提现金额', maxWidth: 300, minWidth: 150 },
                
                {
                    field: 'account_info', 
                    title: '收款用户', 
                    maxWidth: 300, 
                    minWidth: 150,
                    templet: function(d){
                      // 组合显示收款用户信息
                      var html = [];
                      if (d.enc_true_name) {
                        html.push('<div><span style="font-weight:bold;">' + d.enc_true_name + '</span></div>');
                      }
                      if (d.enc_bank_no) {
                        // 显示银行卡号（通常需要脱敏处理）
                        var bankNo = d.enc_bank_no;
                      
                        html.push('<div style="color:#666;margin-top:2px;">银行卡: ' + bankNo + '</div>');
                      }
                      if (d.bank_code) {
                        // 这里假设 bank_code 是银行代码，你可能需要从 banks 表获取银行名称
                        // 如果有 bank_name 字段可以直接使用 d.bank_name
                        html.push('<div style="color:#888;margin-top:2px;">开户行: ' + (d.bank_name) + '</div>');
                      }
                      return html.join('');
                    }
                  },
                { field: 'commission', title: '手续费', maxWidth: 300, minWidth: 150 },
                { field: 'real_amount', title: '实际金额', maxWidth: 300, minWidth: 150 },
                
                {
                    field: 'status', 
                    title: '状态', 
                    width: 200, 
                    templet: function (d) {
                        var statusClass = '';
                        var statusName = '';
                        
                        switch (d.status) {
                            case 0: 
                                statusClass = 'layui-badge layui-bg-orange'; 
                                statusName = "待审核";
                                break;
                            case 1: 
                                statusClass = 'layui-badge layui-bg-blue'; 
                                statusName = "审核通过"; 
                                break;
                            case 2: 
                                statusClass = 'layui-badge layui-bg-prop';
                                statusName = "审核未通过"; 
                                break;
                            case 3: 
                                statusClass = 'layui-badge layui-bg-prop';
                                statusName = "已取消"; 
                                break;
                            default:
                                statusClass = 'layui-badge'; 
                                statusName = "未知状态(" + d.status + ")";
                        }
                        
                        return '<span class="' + statusClass + '">' + statusName + '</span>';
                    }
                },
                { field: 'create_time', title: '申请时间', maxWidth: 300, minWidth: 150 },
                { field: 'confirm_time', title: '打款时间', maxWidth: 300, minWidth: 150 },
            ]],
            page: true,
            limit: 10,
            limits: [10, 20, 30]
        });
        });
</script>
{/block}